package com.ayou.eggguard.farm.service.impl;

import com.ayou.common.utils.PageBean;
import com.ayou.eggguard.farm.mapper.FodderMapper;
import com.ayou.eggguard.farm.pojo.FodderRecord;
import com.ayou.eggguard.farm.service.FodderService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FodderServiceImpl implements FodderService {

    @Autowired
    private FodderMapper fodderMapper;

    @Override
    public PageBean<FodderRecord> getPurchaseRecord(Integer pageNum, Integer pageSize, String number) {
        PageBean<FodderRecord> pb=new PageBean<>();
        PageHelper.startPage(pageNum,pageSize);
        List<FodderRecord> list=fodderMapper.getPurchaseRecord(number);
        Page<FodderRecord> p= (Page<FodderRecord>) list;
        pb.setTotal(p.getTotal());
        pb.setItems(p.getResult());
        return pb;
    }

    @Override
    public void delete(Integer id) {
        fodderMapper.delete(id);
    }

    @Override
    public void add(FodderRecord fodderRecord) {
        fodderMapper.add(fodderRecord);
    }

    @Override
    public void update(FodderRecord fodderRecord) {
        fodderMapper.update(fodderRecord);
    }
}
